package com.crungoo.springaop;

import com.crungoo.services.UserService;
import com.crungoo.springaop.adives.MyAroundAdvice;
import com.crungoo.springaop.adives.MyBeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;

/**
 * @author fujc-dev@qq.com
 * @date 2023/7/28 11:39
 */

public class Test2 {

	public static void main(String[] args) {
		UserService target = new UserService();

		ProxyFactory proxyFactory = new ProxyFactory();
		proxyFactory.setTarget(target);
		// advice的执行先后顺序，取决于传递的顺序
		proxyFactory.addAdvice(new MyBeforeAdvice());
		proxyFactory.addAdvice(new MyAroundAdvice());
		proxyFactory.addAdvice(new MyAroundAdvice());
		UserService proxy = (UserService) proxyFactory.getProxy();
		proxy.test();
	}
}
